#!/bin/sh
# Simple standalone build script for when not building in wine tree

# Figure out what the tools are named
# Varies from system to system
for CROSS in \
    i586-mingw32msvc- \
    i686-pc-mingw32- \
    i686-w64-mingw32- \
    i386-mingw32- \
    "MinGW Not Found "
do
    test `which ${CROSS}windres 2>/dev/null` && break
done

set -e
set -x

if [ ! -d "bin" ]; then
    mkdir bin
fi

# Set WINE include directory
# For each user, please add your own include directory to variable
#INCLUDE="-I${HOME}/wine-git/include -I/usr/local/include/wine/windows"

# INCLUDE copied from wine/include.
# This allows compilation on Windows.
# Warning: GCC header files and WINE header files are not compatible.
#  We are currently getting lucky...
INCLUDE=-I../include
LIB="-loleaut32 -ldxguid -lole32 -lcomdlg32 -luser32 -lcomctl32"
ARGS="-pedantic -ansi -Wall"
CARGS="${ARGS} -c "
GARGS="${ARGS} -g"

${CROSS}windres rsrc.rc -o bin/rsrc.o
${CROSS}gcc ${CARGS} ${INCLUDE} cmdline.c -o bin/cmdline.o
${CROSS}gcc ${CARGS} ${INCLUDE} dxdiagcom.c -o bin/dxdiagcom.o
${CROSS}gcc ${CARGS} ${INCLUDE} directxfiles_tab.c -o bin/directxfiles_tab.o
${CROSS}gcc ${CARGS} ${INCLUDE} displaydialog.c -o bin/displaydialog.o
${CROSS}gcc ${CARGS} ${INCLUDE} globals.c -o bin/globals.o
${CROSS}gcc ${CARGS} ${INCLUDE} input_tab.c -o bin/input_tab.o
${CROSS}gcc ${CARGS} ${INCLUDE} main_dialog.c -o bin/main_dialog.o
${CROSS}gcc ${CARGS} ${INCLUDE} sound_tab.c -o bin/sound_tab.o
${CROSS}gcc ${CARGS} ${INCLUDE} system_tab.c -o bin/system_tab.o
${CROSS}gcc ${CARGS} ${INCLUDE} tab.c -o bin/tab.o
${CROSS}gcc ${CARGS} ${INCLUDE} utility.c -o bin/utility.o
${CROSS}gcc ${GARGS} ${INCLUDE} main.c bin/globals.o bin/rsrc.o bin/directxfiles_tab.o bin/tab.o bin/utility.o bin/main_dialog.o bin/input_tab.o bin/cmdline.o bin/system_tab.o bin/sound_tab.o bin/displaydialog.o bin/dxdiagcom.o ${LIB} -o bin/dxdiag.exe

